using System;

namespace Microsoft.WowAddonStudio.Lua.Parser
{
    public class Error : IComparable<Error>
    {
        internal const int minErr = 50;
        internal const int minWrn = 100;

        private readonly int column;
        private readonly bool isWarning;
        private readonly int length;
        private readonly int line;
        private readonly string message;

        public Error(string message, int line, int column, int length, bool isWarning)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            this.message = message;
            this.line = line;
            this.column = column;
            this.length = length;
            this.isWarning = isWarning;
        }

        public string Message
        {
            get { return message; }
        }

        public int Line
        {
            get { return line; }
        }

        public int Column
        {
            get { return column; }
        }

        public int Length
        {
            get { return length; }
        }

        public bool IsWarning
        {
            get { return isWarning; }
        }

        public int CompareTo(Error error)
        {
            if (line < error.line)
                return -1;
            if (line > error.line)
                return 1;
            if (column < error.column)
                return -1;
            if (column > error.column)
                return 1;

            return 0;
        }

        public bool Equals(Error error)
        {
            return (line == error.line && column == error.column);
        }
    }
}